/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

/**
 * <p>Project: jse2303 - Str4
 * <p>Powered by webrx On 2023-07-17 14:13:50
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Str4 {
    public static void main(String[] args) {
        //字符串倒序
        String str = "abc123程序设计";
        System.out.println(str);
        String ss = "";
        for (int i = 0; i < str.length(); i++) {
            //System.out.println(str.charAt(str.length() - 1 - i));
            ss = str.substring(i, i + 1) + ss;
        }
        System.out.println(ss);

        System.out.println(new StringBuilder(ss).reverse());

        //检查字符串在另一个字符串出现的次数
        String s = "java";
        String s2 = "java,hello,java!!java8-javascript,jav";
        int pos = s2.indexOf(s);
        int n = 0;
        while (pos != -1) {
            ++n;
            pos = s2.indexOf(s, pos + s.length());
        }
        System.out.println(n);
    }
}
